package cn.itcast.order.controller;

import cn.itcast.hmall.dto.common.ResultDTO;
import cn.itcast.hmall.dto.order.OrderReqDTO;
import cn.itcast.hmall.pojo.order.Order;
import cn.itcast.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;
    @PostMapping("/order")
    public String createOrder(@RequestBody OrderReqDTO orderReqDTO){
       return orderService.createOrder(orderReqDTO);
    }
    @GetMapping("/order/{orderId}")
    public Order findOrderById(@PathVariable Long orderId){
        return orderService.getById(orderId);
    }
    @PutMapping("/pay/{orderId}")
    public ResultDTO checkPassword(@PathVariable Long orderId,@RequestBody Map<String,String> keys){
        return orderService.checkPassword(orderId,keys);
    }
}
